package com.zb.zeus.system.api;

import com.zb.zeus.common.core.domain.R;
import com.zb.zeus.common.core.web.domain.AjaxResult;
import com.zb.zeus.common.core.web.page.TableDataInfo;
import com.zb.zeus.common.core.web.page.TableSupport;
import com.zb.zeus.system.api.domain.SysEmployee;
import com.zb.zeus.system.api.factory.RemoteUserFallbackFactory;
import com.zb.zeus.system.api.model.LoginUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

/**
 * 用户服务
 *
 * @author zb.zeus
 */
@FeignClient(contextId = "remoteUserService",
        value = "${feign.ref.service.zeus-system:zeus-system}",
        fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService {
    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @return 结果
     */
    @GetMapping(value = "/user/info/{username}")
    R<LoginUser> getUserInfo(@PathVariable("username") String username);

    /**
     * 通过手机号码获取用户信息(外部用户)
     *
     * @param phn 手机号
     * @return 用户登录信息
     */
    @GetMapping("/user/outerUserInfo/{phn}")
    R<LoginUser> getOuterUserInfo(@PathVariable("phn") String phn);


    @GetMapping(value = "/user/with/token")
    R<LoginUser> getTokenUserInfo(@RequestParam String token);

    @PostMapping(value = "/user/create/token")
//    @Headers({"contentType: application/json"})
    AjaxResult createToken(@RequestBody LoginUser loginUser);

    @PostMapping(value = "/user/refresh/token")
    AjaxResult refreshToken(@RequestBody LoginUser loginUser);

    @GetMapping(value = "/user/del/token")
    AjaxResult delToken(@RequestParam String token);

    /**
     * 分页查询与员工信息
     *
     * @param sysEmployee
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/employee/feign/list")
    TableDataInfo feignList(@SpringQueryMap SysEmployee sysEmployee,
                            @RequestParam(TableSupport.PAGE_NUM) int pageNum,
                            @RequestParam(TableSupport.PAGE_SIZE) int pageSize);

}
